home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / ACORNUSERS / CBSA / EDUCATION / LOADER / cc / WimpIcon < prev    next >
Text File  |  1997-12-07  |  2KB  |  77 lines

  1.  
  2. //-----------------------------------
  3. //             WimpIcon.c
  4. //-----------------------------------
  5.  
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <os.h>
  9. #include <trap.h>
  10. #include "WimpError.h"
  11. #include "WimpIcon.h"
  12.  
  13. WimpIcon::WimpIcon(WimpIcon &icon, int iflags, int window,
  14.                    int priority, int x0, int y0, int x1, int y1)
  15. {
  16.   int r[10];
  17.   os_error *e;
  18.   indirect = icon.indirect;
  19.   flags = iflags;
  20.   handle = window;      // Provisoire
  21.   xmin = x0;
  22.   ymin = y0;
  23.   xmax = x1;
  24.   ymax = y1;
  25.   r[0] = priority;
  26.   r[1] = (int)&handle;
  27.   if ((e = os_swi(Wimp_CreateIcon, r)) != NULL) throw(e);
  28.   handle = r[0];
  29.   window_handle = window; 
  30. }
  31.  
  32. WimpIcon::WimpIcon(char *spritename, int iflags, int window, int priority,
  33.                    int x0, int y0, int x1, int y1)
  34. {
  35.   int r[10];
  36.   os_error *e;
  37.   if (iflags & INDIRECT)
  38.   {
  39.     indirect_sprite.sprite_name = new char[strlen(spritename)+1];
  40.     strcpy(indirect_sprite.sprite_name, spritename);
  41.     indirect_sprite.sprite_area = (int *)1;
  42.     indirect_sprite.isname = 1;
  43.   }
  44.   else strncpy(sprite_name, spritename, 12);
  45.   flags = iflags;
  46.   window_handle = window;
  47.   handle = window;        // Provisoire
  48.   xmin = x0;
  49.   ymin = y0;
  50.   xmax = x1;
  51.   ymax = y1;
  52.   r[0] = priority;
  53.   r[1] = (int) &handle;
  54.   if ((e = os_swi(Wimp_CreateIcon, r)) != NULL) throw(e);
  55.   handle = r[0];  
  56. }
  57.  
  58. void WimpIcon::Delete()
  59. {
  60.   int r[10];
  61.   os_error *e;
  62.   int b[2];
  63.   b[0] = window_handle;
  64.   if (b[0] < -1) b[0] = -2;
  65.   b[1] = handle;
  66.   r[1] = (int) b;
  67.   if ((e = os_swi(Wimp_DeleteIcon, r)) != NULL) throw(e);  
  68. }
  69.  
  70. WimpIcon::~WimpIcon()
  71. {
  72.   if (flags & INDIRECT) delete indirect_sprite.sprite_name;
  73. }
  74.  
  75.  
  76.  
  77.